import http from "@/api";
import qs from "qs";
import { SelectCategoryListRetType } from "./type";

// 使用枚举包含所有Path
enum Api {
  // 分页查询类别列表
  selectTbGoodsCategoryByPage = "/tbGoodsCategory/selectByPage",

  // 删除类别
  deleteTbGoodsCategory = "/tbGoodsCategory/delete",

  // 添加类别
  addTbGoodsCategory = "/tbGoodsCategory/add"
}

// 分页查询类别列表的Api
export const selectTbGoodsCategoryByPageApi = (data: { name: string | null; page: number; size: number }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post<SelectCategoryListRetType>(Api.selectTbGoodsCategoryByPage + dataQ, {}, { loading: false });
};

// 删除类别的Api
export const deleteTbGoodsCategoryApi = (data: { id: number }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.deleteTbGoodsCategory + dataQ, {}, { loading: false });
};

// 添加类别的Api
export const addTbGoodsCategoryApi = (data: { name: string }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.addTbGoodsCategory + dataQ, {}, { loading: false });
};
